const store = {
  currentState: {
    tabName: 'home'
  },

  listeners: [],

  subscribe: (l) => {
    store.listeners.push(l)
  },

  getSnapshot: () => {
    return store.currentState
  },

  reducer: (action) => {
    if (action.type === 'change') {
      return {
        tabName: action.tabName
      }
    }
    return store.currentState
  },

  dispatch: (action) => {
    store.currentState = store.reducer(action)
    store.listeners.map(l => l())
    return action
  }
}

export default store